package com.ruoyi.process.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.process.domain.CleanRecord;
import com.ruoyi.process.mapper.CleanRecordMapper;
import com.ruoyi.process.service.ICleanRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 餐用具清洗消毒记录Service业务层处理
 *
 * @author wng
 * @date 2024-08-04
 */
@Service
public class CleanRecordServiceImpl implements ICleanRecordService {
    @Resource
    private CleanRecordMapper cleanRecordMapper;

    /**
     * 查询餐用具清洗消毒记录
     *
     * @param id 餐用具清洗消毒记录主键
     * @return 餐用具清洗消毒记录
     */
    @Override
    public CleanRecord selectCleanRecordById(Long id) {
        CleanRecord item = cleanRecordMapper.selectCleanRecordById(id);
        item.setTypeName(item.getType().getTypeName());
        return item;
    }

    /**
     * 查询餐用具清洗消毒记录列表
     *
     * @param cleanRecord 餐用具清洗消毒记录
     * @return 餐用具清洗消毒记录
     */
    @Override
    public List<CleanRecord> selectCleanRecordList(CleanRecord cleanRecord) {
        List<CleanRecord> cleanRecords = cleanRecordMapper.selectCleanRecordList(cleanRecord);
        cleanRecords.forEach(item -> {
            item.setTypeName(item.getType().getTypeName());
        });
        return cleanRecords;
    }

    /**
     * 新增餐用具清洗消毒记录
     *
     * @param cleanRecord 餐用具清洗消毒记录
     * @return 结果
     */
    @Override
    public int insertCleanRecord(CleanRecord cleanRecord) {
        cleanRecord.setCreateTime(DateUtils.getNowDate());
        return cleanRecordMapper.insertCleanRecord(cleanRecord);
    }

    /**
     * 修改餐用具清洗消毒记录
     *
     * @param cleanRecord 餐用具清洗消毒记录
     * @return 结果
     */
    @Override
    public int updateCleanRecord(CleanRecord cleanRecord) {
        cleanRecord.setUpdateTime(DateUtils.getNowDate());
        return cleanRecordMapper.updateCleanRecord(cleanRecord);
    }

    /**
     * 批量删除餐用具清洗消毒记录
     *
     * @param ids 需要删除的餐用具清洗消毒记录主键
     * @return 结果
     */
    @Override
    public int deleteCleanRecordByIds(Long[] ids) {
        return cleanRecordMapper.deleteCleanRecordByIds(ids);
    }

    /**
     * 删除餐用具清洗消毒记录信息
     *
     * @param id 餐用具清洗消毒记录主键
     * @return 结果
     */
    @Override
    public int deleteCleanRecordById(Long id) {
        return cleanRecordMapper.deleteCleanRecordById(id);
    }
}
